Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Adds new configuration options to add custom tags (labels) to logs #2743

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

svetlanabrennan
Copy link
Contributor

@svetlanabrennan svetlanabrennan commented Nov 14, 2024

Description

  • Added feature to support adding labels (tags) to logs.
  • Added unit tests

How to Test

Run unit tests.

Related Issues

Closes #2716

TODO

  • Add supportability metrics

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.21%. Comparing base (a7f14de) to head (ab1d2b4).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2743      +/-   ##
==========================================
- Coverage   97.25%   97.21%   -0.05%     
==========================================
  Files         294      294              
  Lines       46233    46267      +34     
==========================================
+ Hits        44965    44977      +12     
- Misses       1268     1290      +22     
Flag Coverage Δ
integration-tests-cjs-18.x 74.26% <28.57%> (-0.04%) ⬇️
integration-tests-cjs-20.x 74.26% <28.57%> (-0.03%) ⬇️
integration-tests-cjs-22.x 74.29% <28.57%> (-0.05%) ⬇️
integration-tests-esm-18.x 49.90% <28.57%> (-0.02%) ⬇️
integration-tests-esm-20.x 49.91% <28.57%> (-0.02%) ⬇️
integration-tests-esm-22.x 49.93% <28.57%> (-0.02%) ⬇️
unit-tests-18.x 88.97% <100.00%> (+<0.01%) ⬆️
unit-tests-20.x 88.97% <100.00%> (+<0.01%) ⬆️
unit-tests-22.x 88.98% <100.00%> (+<0.01%) ⬆️
versioned-tests-18.x 78.97% <74.28%> (-0.20%) ⬇️
versioned-tests-20.x 79.00% <74.28%> (-0.17%) ⬇️
versioned-tests-22.x 79.01% <74.28%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

{
common: { attributes: commonAttrs },
logs: formattedLogs
}
]

// exclude list needs to be case-insensitive
const excludeSet = new Set(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand this conversion of array to set. Cant you just lower case all the keys at initialization of the config option then just do an array.includes check in here?

if (isLogLabelingEnabled(this.agent.config)) {
const configuredLabels = parseLabels(this.agent.config.labels)

configuredLabels.forEach((label) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to encapsulate this into another logging helper function that just returns an object that can be assigned to the common attributes section

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can also prob do this in lib/config/index.js to reconcile what's the labels to keep as this is static

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs PR Review
Development

Successfully merging this pull request may close these issues.

Attach labels (tags) to logs
2 participants